{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 调参过程 发现 n_estimators = 70 效果最好"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "mean_squared_error: 0.021167794248658774\n",
      "score: 0.9792709931042887\n",
      "time used 0 s\n",
      "--------------n_estimators=20------done---------------\n",
      "mean_squared_error: 0.021434761624916733\n",
      "score: 0.9790150458646837\n",
      "time used 0 s\n",
      "--------------n_estimators=30------done---------------\n",
      "mean_squared_error: 0.02104546733031643\n",
      "score: 0.979388315208584\n",
      "time used 0 s\n",
      "--------------n_estimators=40------done---------------\n",
      "mean_squared_error: 0.01997257585768881\n",
      "score: 0.9804185168009111\n",
      "time used 0 s\n",
      "--------------n_estimators=50------done---------------\n",
      "mean_squared_error: 0.020059550529242628\n",
      "score: 0.980334922094661\n",
      "time used 0 s\n",
      "--------------n_estimators=60------done---------------\n",
      "mean_squared_error: 0.019264161154720558\n",
      "score: 0.9810999327859263\n",
      "time used 0 s\n",
      "--------------n_estimators=70------done---------------\n",
      "mean_squared_error: 0.019365792813375124\n",
      "score: 0.9810021162668929\n",
      "time used 1 s\n",
      "--------------n_estimators=80------done---------------\n",
      "mean_squared_error: 0.0193578212362632\n",
      "score: 0.9810097878949059\n",
      "time used 1 s\n",
      "--------------n_estimators=90------done---------------\n",
      "mean_squared_error: 0.019457489249304474\n",
      "score: 0.9809138787497336\n",
      "time used 1 s\n",
      "--------------n_estimators=100------done---------------\n",
      "mean_squared_error: 0.01949559381345599\n",
      "score: 0.9808772162118601\n",
      "time used 1 s\n",
      "--------------n_estimators=110------done---------------\n",
      "mean_squared_error: 0.01994557873922346\n",
      "score: 0.9804444676706392\n",
      "time used 1 s\n",
      "--------------n_estimators=120------done---------------\n",
      "mean_squared_error: 0.02019775232655073\n",
      "score: 0.9802021203433453\n",
      "time used 1 s\n",
      "--------------n_estimators=130------done---------------\n",
      "mean_squared_error: 0.020054993524052548\n",
      "score: 0.9803393016539557\n",
      "time used 1 s\n",
      "--------------n_estimators=140------done---------------\n",
      "mean_squared_error: 0.020227232218093315\n",
      "score: 0.9801737969941098\n",
      "time used 2 s\n",
      "--------------n_estimators=150------done---------------\n",
      "mean_squared_error: 0.020204774888778084\n",
      "score: 0.9801953731387104\n",
      "time used 2 s\n",
      "--------------n_estimators=160------done---------------\n",
      "mean_squared_error: 0.01983847867730823\n",
      "score: 0.9805474307038915\n",
      "time used 2 s\n",
      "--------------n_estimators=200------done---------------\n",
      "everything has done\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAD8CAYAAABpcuN4AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAIABJREFUeJzt3Xt4VNXV+PHvmoTAzIggQpSACihVMeItptpWUWoVxIICWtQC+tpisfZtX1DRWqnSqjUC2tZKtUoreGmtYoVyUX+Kl7YCiVgQjBfAGxcJ2oohMyGBWb8/zgkzhFxOyMycmWR9nmee7HNmzzlrIJk1e5+z9xZVxRhjjGlMwO8AjDHGZDZLFMYYY5pkicIYY0yTLFEYY4xpkiUKY4wxTbJEYYwxpkmWKIwxxjTJEoUxxpgmWaIwxhjTpFy/A0iG7t27a58+ffwOwxhjssobb7zxmar2aK5em0gUffr0oayszO8wjDEmq4jIR17qWdeTMcaYJlmiMMYY0yRLFCYzqMLy5UQuHk91uBuxQA7V4W5ELrkCVqxwnjfG+MIShfFfbS3Ry66iYvAYbptXSL/IGvJ0J/0ia7jt6eOoGPwdopddBbW1fkdqTLtkicL4S5XouKspnb+ZvpE1lMSuZwsF7CaXLRRQEruevlVrKHt2E9FxV1vLwhgfWKIw/lqxgsoFSxkaeZoI4QarRAgzJDqPygVLobQ0zQEaYyx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A3ygqtvcpYLnAV/zOabGbBWRngDuzwqf42mQiIwHLgAu18y6//9InC8Eq9y/md7AShE51NeoPGjPiaLZJV79JiKC07derqoz/Y6nPlW9SVV7q2ofnH+/l1Q1o74Nq+qnwCcicrS765vA2z6GVN/HwGkiEnL/v79JBl1sr2c+MN4tjwee9TGWBonIEJyllYerasTveBKp6luqmq+qfdy/mY3Aye7vaEZrt4misSVe/Y1qH18HxuJ8U/+3+zjf76Cy0I+Ax0RkNXAicIfP8ezhtnSeAlYCb+H8Tfo+eldEngBeB44WkY0ichXwK+BbIvI+zl07v8rAGO8DOgMvuH8vv8+w+LKSjcw2xhjTpHbbojDGGOONJQpjjDFNskRhjDGmSZYojDHGNMkShTHGmCZZojDGGNMkSxTGGGOaZInCGGNMk/4/eOZhkDV92rEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 2. Import libraries and modules\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn import preprocessing\n",
    "from sklearn.ensemble import RandomForestRegressor\n",
    "from sklearn.pipeline import make_pipeline\n",
    "from sklearn.model_selection import GridSearchCV\n",
    "from sklearn.metrics import mean_squared_error, r2_score\n",
    "from sklearn.externals import joblib \n",
    "import time\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "train_data = pd.read_csv('./data/public.train.csv')\n",
    "test_data = pd.read_csv('./data/public.test.csv')\n",
    "\n",
    "# 4. Split data into training and test sets\n",
    "y = train_data['发电量']\n",
    "X = train_data.drop(['发电量','ID'], axis=1)\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, \n",
    "                                                    test_size=0.3, \n",
    "                                                    random_state=123, \n",
    "                                                   )\n",
    "\n",
    "\n",
    "# clf = RandomForestClassifier(n_estimators= 10 ,\n",
    "#                                  random_state=0,\n",
    "#                                  max_depth=None,\n",
    "#                                  max_features=sqrt)\n",
    "scores = []\n",
    "# for nt in [10, 20, 40, 80, 120, 160, 200, 300, 400, 500, 600, 700, 800]:\n",
    "for nt in [20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 200]:\n",
    "    t1 = time.time()\n",
    "    forest = RandomForestRegressor(n_estimators=nt, random_state=123, max_features='sqrt',max_depth=None)\n",
    "    forest.fit(X_train, y_train)\n",
    "    pred = forest.predict(X_test)    \n",
    "    print (\"mean_squared_error:\",mean_squared_error(y_test, pred))\n",
    "    rmse = mean_squared_error(y_test, pred)\n",
    "    score = np.divide(1,1+rmse)\n",
    "    scores.append(score)\n",
    "    print(\"score:\",score)\n",
    "    t2 = time.time() \n",
    "    print('time used %d s' % (t2-t1))\n",
    "    print(\"--------------n_estimators=%d------done---------------\"% nt)\n",
    "print('everything has done')\n",
    "\n",
    "x1 = np.arange(16) \n",
    "y1 = scores\n",
    "plt.plot(x1,y1,label='Frist line',linewidth=3,color='r',marker='o', \n",
    "markerfacecolor='blue',markersize=12) \n",
    "# plt.plot(x2,y2,label='second line') \n",
    "# plt.xlabel('Plot Number') \n",
    "# plt.ylabel('Important var') \n",
    "# plt.title('Interesting Graph\\nCheck it out') \n",
    "# plt.legend() \n",
    "plt.show() \n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
